<cfcomponent output="false">

	<cffunction name="read" output="false" access="public" returntype="src.com.DAC.confluence.UserVO">
		<cfargument name="id" required="true">
		<cfset var qRead="">
		<cfset var obj="">

		<cfquery name="qRead" datasource="stitch">
			select 	person_id, person_username, person_password, person_secretquestion, person_answerquestion
			from tbl_user
			where person_id = <cfqueryparam cfsqltype="CF_SQL_BIGINT" value="#arguments.id#" />
		</cfquery>

		<cfscript>
			obj = createObject("component", "src.com.DAC.confluence.UserVO").init();
			obj.setperson_id(qRead.person_id);
			obj.setperson_username(qRead.person_username);
			obj.setperson_password(qRead.person_password);
			obj.setperson_secretquestion(qRead.person_secretquestion);
			obj.setperson_answerquestion(qRead.person_answerquestion);
			return obj;
		</cfscript>
	</cffunction>



	<cffunction name="create" output="false" access="public">
		<cfargument name="bean" required="true" type="src.com.DAC.confluence.UserVO">
		<cfset var qCreate="">

		<cfset var qGetId="">

		<cfset var local1=arguments.bean.getperson_username()>
		<cfset var local2=arguments.bean.getperson_password()>
		<cfset var local3=arguments.bean.getperson_secretquestion()>
		<cfset var local4=arguments.bean.getperson_answerquestion()>

		<cftransaction isolation="read_committed">
			<cfquery name="qCreate" datasource="stitch">
				insert into tbl_user(person_username, person_password, person_secretquestion, person_answerquestion)
				values (
					<cfqueryparam value="#local1#" cfsqltype="CF_SQL_VARCHAR" />,
					<cfqueryparam value="#local2#" cfsqltype="CF_SQL_VARCHAR" />,
					<cfqueryparam value="#local3#" cfsqltype="CF_SQL_VARCHAR" />,
					<cfqueryparam value="#local4#" cfsqltype="CF_SQL_VARCHAR" />
				)
			</cfquery>

			<!--- If your server has a better way to get the ID that is more reliable, use that instead --->
			<cfquery name="qGetID" datasource="stitch">
				select person_id
				from tbl_user
				where person_username = <cfqueryparam value="#local1#" cfsqltype="CF_SQL_VARCHAR" />
				  and person_password = <cfqueryparam value="#local2#" cfsqltype="CF_SQL_VARCHAR" />
				  and person_secretquestion = <cfqueryparam value="#local3#" cfsqltype="CF_SQL_VARCHAR" />
				  and person_answerquestion = <cfqueryparam value="#local4#" cfsqltype="CF_SQL_VARCHAR" />
				order by person_id desc
			</cfquery>
		</cftransaction>

		<cfscript>
			arguments.bean.setperson_id(qGetID.person_id);
		</cfscript>
		<cfreturn arguments.bean />
	</cffunction>



	<cffunction name="update" output="false" access="public">
		<cfargument name="bean" required="true" type="src.com.DAC.confluence.UserVO">
		<cfset var qUpdate="">

		<cfquery name="qUpdate" datasource="stitch" result="status">
			update tbl_user
			set person_username = <cfqueryparam value="#arguments.bean.getperson_username()#" cfsqltype="CF_SQL_VARCHAR" />,
				person_password = <cfqueryparam value="#arguments.bean.getperson_password()#" cfsqltype="CF_SQL_VARCHAR" />,
				person_secretquestion = <cfqueryparam value="#arguments.bean.getperson_secretquestion()#" cfsqltype="CF_SQL_VARCHAR" />,
				person_answerquestion = <cfqueryparam value="#arguments.bean.getperson_answerquestion()#" cfsqltype="CF_SQL_VARCHAR" />
			where person_id = <cfqueryparam value="#arguments.bean.getperson_id()#" cfsqltype="CF_SQL_BIGINT">
		</cfquery>
		<cfreturn arguments.bean />
	</cffunction>



	<cffunction name="delete" output="false" access="public" returntype="void">
		<cfargument name="bean" required="true" type="src.com.DAC.confluence.UserVO">
		<cfset var qDelete="">

		<cfquery name="qDelete" datasource="stitch" result="status">
			delete
			from tbl_user
			where person_id = <cfqueryparam cfsqltype="CF_SQL_BIGINT" value="#arguments.bean.getperson_id()#" />
		</cfquery>

	</cffunction>


</cfcomponent>